var api = require('../../utils/api.js');
var app = getApp();
Page({

    data: {
        user:[],
        type:'',
        types:[]
    },

    onShow() {
        var that=this;
        api.post({
            url: 'user/index',
            data: {},
            success: data => {
                var info = data.data;
                that.setData({
                    user: info,
                    type: info.types
                })
            }
        })

        api.post({
            url: 'user/gettypes',
            data: {},
            success: data => {
                console.log(data);
                var info = data.data.types;
                that.setData({
                    types: info
                })
            }
        })


    },

    formSubmit(e){
        var data=e.detail.value;

        data.types=this.data.type;
        var that=this;
        api.post({
            url: 'user/setuserinfo',
            data: data,
            success: data => {
                console.log(data);

                wx.showToast({
                  title:data.msg,
                  icon:'none'
                })
            }
        })
    },

    bindPickerChange(ret){
        var i=ret.detail.value;
        var types=this.data.types;



        this.setData({
            type:types[i]
        })
    }

})